using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SimplePoker.Main;

namespace SimplePoker.tests
{
    [TestClass]
    public class RoundTests_AlwaysCallPlayers
    {
        private AlwaysCallPlayer _AlwaysCall1;
        private AlwaysCallPlayer _AlwaysCall2;
        private Round _Round;

        [TestInitialize]
        public void Setup()
        {
            _AlwaysCall1 = new AlwaysCallPlayer("Always Call 1");
            _AlwaysCall2 = new AlwaysCallPlayer("Always Call 2");
            _Round = new Round(_AlwaysCall1, _AlwaysCall2);
        }

        [TestMethod]
        public void if_both_players_call_the_round_ends()
        {
            _Round.DoNextAction();
            _Round.DoNextAction();
            Assert.IsTrue(_Round.HasEnded);
        }

        [TestMethod]
        public void players_have_ante_removed_each_time_a_new_round_starts()
        {
            Assert.AreEqual<int>(999, _AlwaysCall1.ChipCount);
            Assert.AreEqual<int>(999, _AlwaysCall2.ChipCount);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void cannot_start_tournament_playing_against_self()
        {
            var tourney = new Tournament(_AlwaysCall1, _AlwaysCall1);
        }

        [TestMethod]
        public void CallingRemovesZeroChipsFromPlayerIfNoBetsBeforeIt()
        {
            _Round.DoNextAction();
            Assert.AreEqual<int>(999, _AlwaysCall1.ChipCount);
        }

        [TestMethod]
        public void PlayersStartWith1000Chips()
        {
            var player = new AlwaysCallPlayer("AlwaysCallPlayer");
            Assert.AreEqual<int>(1000, player.ChipCount);
        }

        [TestMethod]
        public void pot_size_is_2_after_2_calls()
        {
            _Round.DoNextAction();
            _Round.DoNextAction();
            Assert.AreEqual<int>(2, _Round.PotSize);
        }

        [TestMethod]
        public void when_showdown_the_best_hand_wins_the_pot()
        {
            _AlwaysCall1.Card = new Card(13);
            _AlwaysCall2.Card = new Card(1);
            _Round.DoNextAction();
            _Round.DoNextAction();

            Assert.AreEqual<int>(1001, _AlwaysCall1.ChipCount);
        }

        [TestMethod]
        public void classed_as_a_showdown_if_called_down()
        {
            _Round.DoNextAction();
            _Round.DoNextAction();
            Assert.IsTrue(_Round.IsShowdown);
        }
    }
}
